package com.zr.task.adapter;

import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.zh.baselibrary.base.BaseRecyclerAdapter;
import com.zh.baselibrary.utils.LogUtils;
import com.zh.model.task.home.ValidateBean;
import com.zr.task.R;

import java.util.List;

public class RelationHomeworkAdapter extends BaseRecyclerAdapter<ValidateBean> {

    public RelationHomeworkAdapter(List<ValidateBean> mData) {
        super(mData);
    }

    @Override
    protected int getLayoutId(int viewType) {
        return R.layout.relation_homework_item_layout;
    }

    @Override
    protected void bindData(BaseViewHolder holder, int position, ValidateBean validateBean) {
        TextView mTvSubject = (TextView) holder.getView(R.id.tv_subject);
        TextView mTvPosition = (TextView) holder.getView(R.id.tv_position);
        LinearLayout mRlItem = (LinearLayout) holder.getView(R.id.rl_item);
        TextView mTvRediaCode = (TextView) holder.getView(R.id.tv_redia_code);
        ImageView mIvClose = (ImageView) holder.getView(R.id.iv_close);
        mTvPosition.setText(String.valueOf(position + 1));
        mTvRediaCode.setText(validateBean.getRadioCode());
        mTvSubject.setText(validateBean.getSubjectName());
        mIvClose.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                LogUtils.e("click-adpter");
                onItemViewClickListener.onItemViewClick(v,position);
            }
        });
        if (position == mData.size() - 1) {
            mTvSubject.setTextColor(mContext.getResources().getColor(R.color.white));
            mTvRediaCode.setTextColor(mContext.getResources().getColor(R.color.white));
            mTvPosition.setTextColor(mContext.getResources().getColor(R.color.white));
            mRlItem.setBackgroundColor(mContext.getResources().getColor(R.color.task_theme_color));
            mIvClose.setImageDrawable(mContext.getResources().getDrawable(R.drawable.close_whtite));
        } else {
            mTvSubject.setTextColor(mContext.getResources().getColor(R.color.black));
            mTvRediaCode.setTextColor(mContext.getResources().getColor(R.color.black));
            mTvPosition.setTextColor(mContext.getResources().getColor(R.color.black));
            mRlItem.setBackgroundColor(mContext.getResources().getColor(R.color.white));
            mIvClose.setImageDrawable(mContext.getResources().getDrawable(R.drawable.close_black));
        }
    }
}
